import Vue from 'vue'
import Vuex from 'vuex'
import persist from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    backColor: 'pink',
    tasks: []
  },
  mutations: {
    changeBackColor(state, value) {
      state.backColor = value
    },

    changeTasks(state, value) {
      let obj = {
        name: value,
        state: 1, // 1表示未完成 2表示已完成 3表示已取消
        id: new Date().getTime()
      }
      state.tasks.push(obj)
    }
  },
  actions: {
  },
  modules: {
  },

  plugins: [
    persist()
  ]
})
